package config;

import org.json.simple.JSONObject;

import util.KIntChange;
import util.KJsonObject;
import util.KPrintInfo;

public class ChatConfig {
	static private ChatConfig chatConfig = new ChatConfig();
	private JSONObject jsonObject;
	
	private int only;
	private int world;

	static public ChatConfig getInstance() {
		return chatConfig;
	}

	public void init() {
		if (loadConfing()) {
			KPrintInfo.println("chat----config----加载配置文件成功");
		} else {
			KPrintInfo.println("chat----config----加载配置文件失败");
		}
	}

	/**
	 * 加载配置文件
	 * 
	 * @return
	 */
	public Boolean loadConfing() {
		LoadFile loadFile = new LoadFile();

		String fileString = loadFile.Load("config/chat/chatConfig");
		jsonObject = KJsonObject.decode(fileString);

		return initConfigData();
	}
	private Boolean initConfigData() {
		world = KIntChange.intChange(jsonObject.get("world"));
		only = KIntChange.intChange(jsonObject.get("only"));
	
		return true;
	}
	
	public int getWorld(){
		return world;
	}
	
	public int getOnly(){
		return only;
	}
	///end class
}
